package cn.humaohua.study.yanmo_design_pattern.ch10.va;

/**
 * 中介者模式
 */
public class Main {
    public static void main(String[] args) {
        // 1 : 创建中介者--主板对象
        Motherboard mediator = new Motherboard();
        // 2：创建同事类
        CDDriver cd = new CDDriver(mediator);
        CPU cpu = new CPU(mediator);
        VideoCard vc = new VideoCard(mediator);
        SoundCard sc = new SoundCard(mediator);

        // 3: 让中介者知道所有同事
        mediator.setCdDriver(cd);
        mediator.setCpu(cpu);
        mediator.setVideoCard(vc);
        mediator.setSoundCard(sc);

        // 4:开始看电影，把光盘放入光驱
        cd.readCD();
    }
}
